import axios from 'axios'

// 基本路径
// const baseURLs = 'http://192.168.124.18:8090'  //本地
 export const baseURLs = 'http://xmoa.hzhuishi.cn/index.php/'; //线上  http://xmoa.hzhuishi.cn/index.php /api/index.php/
let form = {
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',


    }
}
let origin = {
  headers: {
      'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',


  }
}
// export const baseURLs = 'http://xmoa.hzhuishi.cn/index.php/'; crossOrigin = "Anonymous"  'Access-Control-Allow-Origin': '*'
let formData = {
    headers: {
        'Content-Type': 'multipart/form-data'
    }
}

axios.defaults.timeout = 5000;
axios.defaults.baseURL = baseURLs
import qs from 'qs'
// 获取验证码
export const get_code = (confing) => {
    return axios.post('login/get_code',qs.stringify(confing),form).then(res => res.data)
}
// 登录
export const login = (confing) => {
    return axios.post('login/login', qs.stringify(confing),form).then(res => res.data)
}
// 注销
export const logout = (confing) => {
    return axios.post('login/logout', qs.stringify(confing),form).then(res => res.data)
}
// 获取用户信息
export const index = (confing) => {
    return axios.post('index/index', qs.stringify(confing),form).then(res => res.data)
}
// 获取用户工资信息
export const get_wages = (confing) => {
    return axios.post('index/get_wages', qs.stringify(confing),form).then(res => res.data)
}
//获取团队信息
export const get_team_infos = (confing) => {
    return axios.post('index/get_team_infos', qs.stringify(confing),form).then(res => res.data)
}
//获取首页公告列表
export const get_news = (confing) => {
    return axios.post('index/get_news', qs.stringify(confing),form).then(res => res.data)
}
//获取设置中员工须知列表
export const get_staff = (confing) => {
    return axios.post('index/get_staff', qs.stringify(confing),form).then(res => res.data)
}
//获取设置中通知列表
export const get_notice = (confing) => {
    return axios.post('index/get_notice', qs.stringify(confing),form).then(res => res.data)
}
//获取公告列表详情
export const get_newsinfo = (confing) => {
    return axios.post('index/get_newsinfo', qs.stringify(confing),form).then(res => res.data)
}
//获取导师信息
export const get_parent_info = (confing) => {
    return axios.post('index/get_parent_info', qs.stringify(confing),form).then(res => res.data)
}
//获取佣金详情
export const get_wages_details = (confing) => {
    return axios.post('index/get_wages_details', qs.stringify(confing),form).then(res => res.data)
}
//获取团队详情
export const get_team_details = (confing) => {
    return axios.post('index/get_team_details', qs.stringify(confing),form).then(res => res.data)
}
//根据会员级别获取会员列表
export const get_members_by_type = (confing) => {
    return axios.post('index/get_members_by_type', qs.stringify(confing),form).then(res => res.data)
}
//获取已结算工资
export const get_total_wages = (confing) => {
    return axios.post('index/get_total_wages', qs.stringify(confing),form).then(res => res.data)
}
//获取每月工资信息
export const get_wages_by_monty = (confing) => {
    return axios.post('index/get_wages_by_monty', qs.stringify(confing),form).then(res => res.data)
}
//获取充值订单信息
export const get_orders = (confing) => {
    return axios.post('index/get_orders', qs.stringify(confing),form).then(res => res.data)
}
//获取累计工资信息
export const get_wages_details_total = (confing) => {
    return axios.post('index/get_wages_details_total', qs.stringify(confing),form).then(res => res.data)
}
//根据查询条件查询工资详情列表
export const query_wages_list = (confing) => {
    return axios.post('index/query_wages_list', qs.stringify(confing),form).then(res => res.data)
}
//根据查询条件查询未结算工资详情列表
export const query_wages_list_notcutoff = (confing) => {
    return axios.post('index/query_wages_list_notcutoff', qs.stringify(confing),form).then(res => res.data)
}
//获取游戏账户列表
export const get_game_account_list = (confing) => {
    return axios.post('index/get_game_account_list', qs.stringify(confing),form).then(res => res.data)
}
//获取推广二维码
export const get_qrcode = (confing) => {
    return axios.post('index/get_qrcode', qs.stringify(confing),form).then(res => res.data)
}
//获取用户选择推广页图
export const get_qrcode_img = (confing) => {
    return axios.post('index/get_qrcode_img', qs.stringify(confing),origin).then(res => res.data)
}
//获取推广页列表
export const get_promotion = (confing) => {
    return axios.post('index/get_promotion', qs.stringify(confing),form).then(res => res.data)
}
//修改用户推广页面
export const get_edit_promotion = (confing) => {
    return axios.post('index/get_edit_promotion', qs.stringify(confing),form).then(res => res.data)
}
//获取银行卡信息
export const get_bankinfo = (confing) => {
    return axios.post('index/get_bankinfo', qs.stringify(confing),form).then(res => res.data)
}
//添加银行卡
export const add_bank = (confing) => {
    return axios.post('index/add_bank', qs.stringify(confing),form).then(res => res.data)
}
//修改银行卡信息
export const save_bankinfo = (confing) => {
    return axios.post('index/save_bankinfo', qs.stringify(confing),form).then(res => res.data)
}
//代理商分组列表
export const proxy_gid_list = (confing) => {
    return axios.post('index/proxy_gid_list', qs.stringify(confing),form).then(res => res.data)
}
//添加代理商分组
export const proxy_gid_add = (confing) => {
    return axios.post('index/proxy_gid_add', qs.stringify(confing),form).then(res => res.data)
}
//修改代理商分组
export const proxy_gid_edit = (confing) => {
    return axios.post('index/proxy_gid_edit', qs.stringify(confing),form).then(res => res.data)
}
//修改代理展示
export const proxy_gid_show_list = (confing) => {
    return axios.post('index/proxy_gid_show_list', qs.stringify(confing),form).then(res => res.data)
}
//删除代理商分组
export const proxy_gid_del = (confing) => {
    return axios.post('index/proxy_gid_del', qs.stringify(confing),form).then(res => res.data)
}
//添加登录器
export const login_launcher_add = (confing) => {
    return axios.post('index/login_launcher_add', qs.stringify(confing),form).then(res => res.data)
}
//登录器列表
export const login_launcher_list = (confing) => {
    return axios.post('index/login_launcher_list', qs.stringify(confing),form).then(res => res.data)
}
//修改登录器
export const login_launcher_edit = (confing) => {
    return axios.post('index/login_launcher_edit', qs.stringify(confing),form).then(res => res.data)
}
//获取注册页面的参数
export const register_page = (confing) => {
    return axios.post('index/register_page', qs.stringify(confing),form).then(res => res.data)
}
//验证手机号
export const check_phone_number = (confing) => {
    return axios.post('login/check_phone_number', qs.stringify(confing),form).then(res => res.data)
}
//获取注册手机验证码
export const get_register_code = (confing) => {
    return axios.post('login/get_register_code', qs.stringify(confing),form).then(res => res.data)
}
//验证用户名是否可用
export const check_username = (confing) => {
    return axios.post('login/check_username', qs.stringify(confing),form).then(res => res.data)
}
//注册
export const register = (confing) => {
    return axios.post('login/register', qs.stringify(confing),form).then(res => res.data)
}
//查询注册结果
export const get_register_result = (confing) => {
    return axios.post('login/get_register_result', qs.stringify(confing),form).then(res => res.data)
}
//获取问题列表
export const get_problem_list = (confing) => {
    return axios.post('index/get_problem_list', qs.stringify(confing),form).then(res => res.data)
}
//获取问题的一级菜单
export const get_problem_menu = (confing) => {
    return axios.post('index/get_problem_menu', qs.stringify(confing),form).then(res => res.data)
}
//获取问题的二级菜单
export const get_problem_submenu = (confing) => {
    return axios.post('index/get_problem_submenu', qs.stringify(confing),form).then(res => res.data)
}
//图片上传
export const image = (confing) => {
    return axios.post('index/image', qs.stringify(confing),form).then(res => res.data)
}
//添加问题
export const add_problem = (confing) => {
    return axios.post('index/add_problem', qs.stringify(confing),form).then(res => res.data)
}
//获取问题详情
export const get_problem = (confing) => {
    return axios.post('index/get_problem', qs.stringify(confing),form).then(res => res.data)
}
//解决问题
export const solve_problem = (confing) => {
    return axios.post('index/solve_problem', qs.stringify(confing),form).then(res => res.data)
}
//是否是代理展示我的分组
export const proxy_gid_judge = (confing) => {
    return axios.post('index/proxy_gid_judge', qs.stringify(confing),form).then(res => res.data)
}
//获取微信登录用户的openid
export const get_wx_openid = (confing) => {
    return axios.post('login/get_wx_openid', qs.stringify(confing),form).then(res => res.data)
}
//验证手机号是否注册
export const check_tel = (confing) => {
    return axios.post('login/check_tel', qs.stringify(confing),form).then(res => res.data)
}
//绑定手机号
export const bind_tel_openid = (confing) => {
    return axios.post('login/bind_tel_openid', qs.stringify(confing),form).then(res => res.data)
}






// 配置请求拦截
// 添加请求拦截器
export const usertel =JSON.parse(localStorage.getItem('tel')) ;
axios.interceptors.request.use(
  config => {

        return config
}, error => {
  console.log(err)
    return Promise.reject(err);
  });
//http response 拦截器
axios.interceptors.response.use(
  response => {
    const Token = localStorage.getItem("tel");
    var url = document.location.toString();
    var arrUrl = url.split("//");

    var start = arrUrl[1].indexOf("/");
    var relUrl = arrUrl[1].substring(start);//stop省略，截取从start开始到结尾的所有字符
    if(relUrl.indexOf("?") != -1){
    　　relUrl = relUrl.split("?")[0];
    }
    if(relUrl!='/#/login' && Token===null && relUrl!='/#/reg' && relUrl!='/' && relUrl!='/#/downLoad'){
        location.href = '/#/login'
    }
    return response;
  },
  error => {
    return Promise.reject(error)
  }
)
